var stompClient = null;
$(function () {
    connect();
});

function connect() {
    var socket = new SockJS('/endpointWisely'); //链接SockJS 的endpoint 名称为"/endpointWisely"
    stompClient = Stomp.over(socket);//使用stomp子协议的WebSocket 客户端
    stompClient.connect({}, function (frame) {//链接Web Socket的服务端。
        console.log('Connected: ' + frame);
        stompClient.subscribe('/topic/index', function (response) { //订阅/topic/index
            alert(response);
        });
    });
}